
#对list进行切片 从1开始，4结束，步长1
my_list = [0,1,2,3,4,5,6,7,8,9]
result = my_list[1:4:1]
print(result)

#对tuple进行切片 从头开始，到最后结束
my_tuple = (0,1,2,3,4,5,6,7,8,9)
result1 = my_tuple[:] #从开头到结束
print(result1)

##对str进行切片 从头开始到尾结束 步长为2
my_str = "wo shi ni ba ba"
result2 = my_str[::2]
print(result2)

#对str进行切片 从头开始到尾结束 步长为-1
#这个等同于反转字符串
my_str = "wo shi ni ba ba"
result3 = my_str[::-1]
print(result3)

#对列表进行切片 3开始 1结束 步长为-1
my_list = [0,1,2,3,4,5,6,7,8,9]
result4 = my_list[3:1:-1]
print(result4)

#对元组进行切片 步长为-2 从头开始，到最后结束
my_tuple = (0,1,2,3,4,5,6,7,8,9)
result5 = my_tuple[::-2]
print(result5)